import axios from 'axios'
import nprogress from 'nprogress'
import 'nprogress/nprogress.css'
const requests = axios.create({
  baseURL: 'http://39.98.123.211/api',
  // 请求超时时间
  timeout: 5000
})
// console.log(nprogress)
// start开始
// 拦截器
requests.interceptors.request.use((config) => {
  // config里面的属性有一个是请求头,headers
  nprogress.start()
  return config
})

// 拦截器
requests.interceptors.response.use(

  (res) => {
    setTimeout(() => nprogress.done(), 1000)

    return res.data
  }
  ,
  () => {}
)

export default requests
